package com.atguigu.order.controller;

import com.atguigu.order.service.OrderService;
import com.atguigu.param.OrderParam;
import com.atguigu.param.PageParam;
import com.atguigu.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("save")
    public R save(@RequestBody OrderParam orderParam){

        return orderService.save(orderParam);
    }

    @PostMapping("list")
    public R list(@RequestBody Map<String,Integer> map){

        Integer userId = map.get("user_id");
        return orderService.list(userId);
    }

    @GetMapping("admin/list")
    public R adminList(@RequestBody PageParam pageParam){

        return orderService.adminList(pageParam);
    }

}
